package com.timer;
import java.util.concurrent.DelayQueue;
public class Consumer implements Runnable {
    // 延时队列 ,消费者从其中获取消息进行消费
    private DelayQueue<Message> queue;

    public Consumer(DelayQueue<Message> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Message take = queue.take();
                String applyOrderId = take.getBody();
                System.out.println(applyOrderId + "线程号===" + take.getId()); //
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
